package com.ruoyi.system.designpattern.visitor;

// 测试类
public class Main {
    public static void main(String[] args) {
        // 创建商品
        Element book = new Book("Java Design Patterns", 65.99, 10);
        Element cd = new CD("Best of Jazz", 19.99, 5);
        Element dvd = new DVD("Inception", 29.99, 3);

        // 创建商店并添加商品
        Store store = new Store();
        store.addProduct(book);
        store.addProduct(cd);
        store.addProduct(dvd);

        // 创建访问者
        Visitor shoppingCart = new ShoppingCartVisitor();
        Visitor inventory = new InventoryVisitor();

        System.out.println("--- 计算价格 ---");
        store.accept(shoppingCart);

        System.out.println("\n--- 清点库存 ---");
        store.accept(inventory);
    }
}
